package cn.always.xiajia.framework.common.enums;

import java.util.Arrays;

import cn.always.xiajia.framework.common.core.IntArrayValuable;
import cn.hutool.core.util.ObjUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 通用状态枚举
 * 
 * @author xgj
 *
 */
@Getter
@AllArgsConstructor
public enum CommonStatusEnum implements IntArrayValuable {

	ENABLE(0, "开启/正常"), // 开启
	DISABLE(1, "关闭/停用"); // 关闭

	public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CommonStatusEnum::getStatus).toArray();

	/**
	 * 状态值
	 */
	private final Integer status;
	/**
	 * 状态名
	 */
	private final String name;

	@Override
	public int[] array() {
		return ARRAYS;
	}

	public static boolean isEnable(String status) {
		return ObjUtil.equal(ENABLE.status, status);
	}

	public static boolean isDisable(String status) {
		return ObjUtil.equal(DISABLE.status, status);
	}

	/**
	 * 是否相同
	 * 
	 * @param commonStatusEnum
	 * @param status
	 * @return
	 */
	public static boolean isSame(CommonStatusEnum commonStatusEnum, String status) {
		return ObjUtil.equal(commonStatusEnum, status);
	}
}
